package br.com.estudante.mvc.logica;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import br.com.estudante.modelo.Estudante;

public class Lista {
	
	public List<Estudante> getLista() {
		
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("Estudante");
		EntityManager manager = factory.createEntityManager();	
		
		Query query = manager.createQuery("SELECT e FROM Estudante e");
		List<Estudante> estudantes = query.getResultList();
		
		manager.close();
		factory.close();
		
		return estudantes;
	}

}
